var nodemailer = require('nodemailer')
var transporter = nodemailer.createTransport({
	service: 'qq',
	auth: {
		user: '986294216@qq.com', 
		pass: 'ozsfrxnaqnribeca' 
	}
});

function putEmail(use) {
	return new Promise((resolve,reject) => {
		console.log(use.to)
		use.to=use.to.slice(1,use.to.length-1)
		use.to=use.to.split(',')
		console.log(use.to)
		var mailOptions = {
			 from: '邢力<986294216@qq.com>', 
			 to: use.to, 
			 subject: use.title,
			 html: use.content,
			 url: use.url
		};
		transporter.sendMail(mailOptions, function(err, info) {
			if (err) {
				let data={
					status:0,
					msg:err,
					result:''
				}
				resolve(data)
			}else {
				let data={
					status:1,
					msg:'',
					result:info
				}
				resolve(data)
			}
			
		});

	})
}

module.exports = putEmail;